﻿@model List<LeadMaster.Models.LeadGroupQuestions>

<div>
<table class="listtable contactstable" cellspacing="0" cellpadding="0" style="width: 1100px;" id="enquirylist">
<thead>
    <tr>
    <th class="tableheader">Question</th>
    <th class="tableheader">Answer Type</th>
    <th class="tableheader">Char</th>
    <th class="tableheader">Logic</th>
    <th class="tableheader">Num From</th>
    <th class="tableheader">Num To</th>
    <th class="tableheader">Mandatory</th>
    <th class="tableheader">Pri / Sec</th>
    <th class="tableheader">Display Order</th>
    <th class="tableheader"></th>
    </tr>
</thead>
@foreach (var item in Model)
{
    <tr>
    <td><label class="selectgroupquestion" data-groupquestionid="@(item.LeadGroupQuestionsID)" style="cursor: pointer; color: #333333;">@item.Question</label></td>
    <td><label>@item.AnswerType</label></td>
    <td><label>@item.AcceptedAnswerChar</label></td>
    <td><label>@item.AcceptedAnswerBool</label></td>
    <td><label>@item.AcceptedAnswerIntFrom</label></td> 
    <td><label>@item.AcceptedAnswerIntTo</label></td>
    <td><label>@item.Mandatory</label></td>
    <td><label>@item.PrimarySecondary</label></td>
    <td><label>@item.DisplayOrder</label></td>
    <td><img src="~/Images/delete.ico" style="width: 20px; height: 20px" class="deletegroupquestion" data-groupquestionid="@(item.LeadGroupQuestionsID)"/></td>
        
    </tr>
}
</table>
</div>

<input id="btnAskGroupQuestions" type="button" value="Create Question" data-leadgroupid="@(ViewBag.LeadGroupId)"/>

<div id="askgroupquestions">
</div>

<script type="text/javascript">
    $(document).ready(function () {

        $("#askgroupquestions").dialog(
        {
            autoOpen: false,
            width: 1100,
            open: function () { $(".ui-dialog").css("box-shadow", "#000 5px 5px 5px"); },
            position: ['middle', 20],
            modal: true,
            dialogClass: 'notitle',
            buttons: {
                save: function () {
                    $(this).dialog("close");
                    $("#formAskGroupQuestion").submit();
                },
                cancel: function () {
                    $(this).dialog("close");
                }
            }
        });

        $("#btnAskGroupQuestions").click(function () {
            $("#askgroupquestions").dialog("open");
            $('#askgroupquestions').html('<div style="text-align: center;"><div><img src="@Url.Content("~/Images/ajaxspinner_large.gif")" alt="Loading..." style="margin: 20px;" /></div><div>Loading...</div></div>');
            var contactURL = '@(Url.Action("CreateGroupQuestions", "LeadBuilder"))/?id=' + $(this).data("leadgroupid");
            $('#askgroupquestions').load(contactURL);
        });

        $(".selectgroupquestion").click(function () {
            $("#askgroupquestions").dialog("open");
            $('#askgroupquestions').html('<div style="text-align: center;"><div><img src="@Url.Content("~/Images/ajaxspinner_large.gif")" alt="Loading..." style="margin: 20px;" /></div><div>Loading...</div></div>');
            var contactURL = '@(Url.Action("EditGroupQuestion", "LeadBuilder"))/?id=' + $(this).data("groupquestionid");
            $('#askgroupquestions').load(contactURL);
        });

        $(".deletegroupquestion").click(function () {
            var ans=confirm("Are you sure you wish to delete this question ?")
            if (ans==true) {
                var contactURL = '@(Url.Action("DeleteGroupQuestion", "LeadBuilder"))/?id=' + $(this).data("groupquestionid");
                $('#groupquestions').load(contactURL);
            }
        });

    });
</script>